cmake_minimum_required(VERSION 3.10)
project(card_game_server)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


file(GLOB SOURCE_FILES
    "*.cc"
    "*.cpp"
    "*.cxx"
    "*.c"
)

add_executable(main ${SOURCE_FILES})

target_include_directories(main PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include
    ${CMAKE_CURRENT_SOURCE_DIR}/third_party/muduo/include
    ${CMAKE_CURRENT_SOURCE_DIR}/DBConnectionPool/include
    ${CMAKE_CURRENT_SOURCE_DIR}/protocol
    /usr/include/mysql
    /usr/local/include
)

target_link_libraries(main
    ${CMAKE_CURRENT_SOURCE_DIR}/third_party/muduo/lib/libmuduo_net.a
    ${CMAKE_CURRENT_SOURCE_DIR}/third_party/muduo/lib/libmuduo_base.a
    ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/lib64/libjsoncpp.a
    ${CMAKE_CURRENT_SOURCE_DIR}/DBConnectionPool/lib/libDBConnectionPool.a
    /usr/lib64/mysql/libmysqlclient.so
    /usr/local/lib64/libredis++.so.1
    ssl
    crypto
    boost_system
    redis++
    hiredis
    pthread
)

target_compile_definitions(main PRIVATE
    JSONCPP_ENABLE_STRING_VIEW=1
)


set(DEFAULT_ROOT_PATH "${CMAKE_SOURCE_DIR}" CACHE PATH "项目根目录")
add_definitions(-DROOT_PATH="${DEFAULT_ROOT_PATH}")


if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_compile_options(main PRIVATE -g)
endif()